<?php

/*
  VoIP Wholesale 1.0
  ------------------
  Document   : module_external_home
  Created on : Nov 18, 2011, 10:15:00 PM
  Author     : Milos Jovanovic <miloscode@gmail.com>
  Description:

 */
?>
<div id="page-title"><?=$carrier['username']?></div>

<div id="page-desc"></div>

<div class="ui-widget"> 
    <div id="content">
        <fieldset>
        <!-- PAGE CONTENT -->
	<form action="" method="post" id="new-carrier" onsubmit="return false;"> 

		<div class="top">
		<fieldset id="contract_type_information" class="ui-widget-content ui-corner-all">	
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_contract_type_information')?></legend>
				<p>
                        <select name='data[contract_type]' id="contract_type">
                            <option value="we_buy_from_them" <?php if($carrier['contract_type'] == "we_buy_from_them"){?>selected="selected"<?php }?>><?=lang('term_we_buy_from_them')?></option>
							<option value="we_sell_to_them" <?php if($carrier['contract_type'] == "we_sell_to_them"){?>selected="selected"<?php }?>><?=lang('term_we_sell_to_them')?></option>
							<option value="bi_lateral" <?php if($carrier['contract_type'] == "bi_lateral"){?>selected="selected"<?php }?>><?=lang('term_bilateral')?></option>
                        </select>
                </p>
				<p>
					<table class="special_numbers_table">
						<tr>
							<td>
								<input type="radio" name="data[special_numbers_only]" value="0" <?php if($carrier['special_numbers_only'] == "0"){?>checked="checked"<?php }?>>
							</td>
							<td>
								<?=lang('text_wholesale')?> (<?=lang('text_wholesale_abbreviation')?>)
							</td>
							<td>
								<input type="radio" name="data[special_numbers_only]" value="1" <?php if($carrier['special_numbers_only'] == "1"){?>checked="checked"<?php }?>>
							</td>	
							<td>
								<?=lang('text_special_services')?> (<?=lang('text_special_services_abbreviation')?>)
							</td>
						</tr>
					</table>				
				</p>
		</fieldset>
	
		</div>
	
		<div class="left">
		
		<fieldset id="general_information" class="ui-widget-content ui-corner-all">
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_general_information')?></legend>
				<p>
					<label><?=lang('term_legal_name')?></label> 
					<input type="text" name="data[legal_name]" id="legal_name" class="text ui-widget-content ui-corner-all" value="<?=$carrier['legal_name']?>"/> 
                </p>
				<p>
					<label><?=lang('term_username')?></label> 
					<input type="text" name="data[username]" id="username" class="text ui-widget-content ui-corner-all ui-state-disabled deactivated"  value="<?=$carrier['username']?>"/> 
					<p id="username_status"></p>
                </p>
				<p>
					<label><?=lang('term_password')?></label> 
					<input type="password" name="data[password]" id="password" class="text ui-widget-content ui-corner-all" /> 
                </p>
				<p>
					<label><?=lang('term_password_repeat')?></label> 
					<input type="password" name="data[password_repeat]" id="password_repeat" class="text ui-widget-content ui-corner-all" /> 
                </p>
		</fieldset>
		<fieldset id="contact_information" class="ui-widget-content ui-corner-all">			
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_contact_information')?></legend>
				<p>
					<label><?=lang('term_sales_name')?></label> 
					<input type="text" name="data[sales_name]" id="sales_name" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['sales_name']?>"/> 
                </p>
				<p>
					<label><?=lang('term_sales_emails')?></label> 
					<textarea name="data[sales_emails]" id="sales_emails" class="text ui-widget-content ui-corner-all"><?=$carrier['sales_emails']?></textarea>
                </p>
				<p>
					<label><?=lang('term_sales_phone')?></label> 
					<input type="text" name="data[sales_phone]" id="sales_phone" class="text ui-widget-content ui-corner-all" value="<?=$carrier['sales_phone']?>"/> 
                </p>	
				<br /><br />
				<p>
					<label><?=lang('term_billing_name')?></label> 
					<input type="text" name="data[billing_name]" id="billing_name" class="text ui-widget-content ui-corner-all" value="<?=$carrier['billing_name']?>"/> 
                </p>
				<p>
					<label><?=lang('term_billing_emails')?></label> 
					<textarea name="data[billing_emails]" id="billing_emails" class="text ui-widget-content ui-corner-all"><?=$carrier['billing_emails']?></textarea>
                </p>
				<br /><br />
				<p>
					<label><?=lang('term_noc_name')?></label> 
					<input type="text" name="data[noc_name]" id="noc_name" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['noc_name']?>"/> 
                </p>
				<p>
					<label><?=lang('term_noc_emails')?></label> 
					<textarea name="data[noc_emails]" id="noc_emails" class="text ui-widget-content ui-corner-all"><?=$carrier['noc_emails']?></textarea>
                </p>
				<p>
					<label><?=lang('term_noc_phone')?></label> 
					<input type="text" name="data[noc_phone]" id="noc_phone" class="text ui-widget-content ui-corner-all" value="<?=$carrier['noc_phone']?>"/>
                </p>
				<br /><br />
				<p>
					<label><?=lang('term_legal_emails')?></label> 
					<textarea name="data[legal_emails]" id="legal_emails" class="text ui-widget-content ui-corner-all"><?=$carrier['legal_emails']?></textarea>
                </p>
				<br /><br />
				<p>
					<label class="rates-buy-emails"><?=lang('term_rates_buy_emails')?></label> 
					<textarea name="data[rates_buy_emails]" id="rates_buy_emails" class="text ui-widget-content ui-corner-all"><?=$carrier['rates_buy_emails']?></textarea>
                </p>
				<p>
					<label class="rates-sell-emails"><?=lang('term_rates_sell_emails')?></label> 
					<textarea type="text" name="data[rates_sell_emails]" id="rates_sell_emails" class="text ui-widget-content ui-corner-all"><?=$carrier['rates_sell_emails']?></textarea>
                </p>				
		</fieldset>	
		<fieldset id="regional_information" class="ui-widget-content ui-corner-all">	
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_regional_information')?></legend>
				<p class="time-zone-buy">
					<label><?=lang('term_timezone_buy')?></label> 
					<?=timezone_menu($carrier['timezone_buy'],"time-zone-buy-select","data[timezone_buy]")?>
                </p>				
				<p class="time-zone-sell">
					<label><?=lang('term_timezone_sell')?></label> 
					<?=timezone_menu($carrier['timezone_sell'],"time-zone-sell-select","data[timezone_sell]")?>
                </p>
				<br />
				<p class="currency-id">
					<label><?=lang('term_currency')?></label> 
					<?=$this->PACKAGE->regional->currencies->generate_menu("currency","data[currency_id]",$carrier['currency_id'])?>
                </p>						

		</fieldset>
		
		</div>
		<div class="right">		
		<fieldset id="address_information" class="ui-widget-content ui-corner-all">		
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_carrier_information')?></legend>
				<p>
					<label><?=lang('term_address_line_1')?></label> 
					<input type="text" name="data[address_line_1]" id="address_line_1" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['address_line_1']?>"/> 
                </p>
				<p>
					<label><?=lang('term_address_line_2')?></label> 
					<input type="text" name="data[address_line_2]" id="address_line_2" class="text ui-widget-content ui-corner-all" value="<?=$carrier['address_line_2']?>" /> 
                </p>
				<p>
					<label><?=lang('term_state')?></label> 
					<input type="text" name="data[state]" id="state" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['state']?>"/> 
                </p>			
				<p>
					<label><?=lang('term_city')?></label> 
					<input type="text" name="data[city]" id="city" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['city']?>"/> 
                </p>
				<p>
					<label><?=lang('term_zip')?></label> 
					<input type="text" name="data[zip]" id="zip" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['zip']?>"/> 
                </p>
				<p>
					<label><?=lang('term_company_phone')?></label> 
					<input type="text" name="data[company_phone]" id="company_phone" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['company_phone']?>"/> 
                </p>				
				<p>
					<label><?=lang('term_website')?></label> 
					<input type="text" name="data[website]" id="website" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['website']?>"/> 
                </p>	
				<p>
					<label><?=lang('term_registration_id')?></label> 
					<input type="text" name="data[registration_id]" id="registration_id" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['registration_id']?>"/> 
                </p>	
				<p>
					<label><?=lang('term_vat_id')?></label> 
					<input type="text" name="data[vat_id]" id="vat_id" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['vat_id']?>"/> 
                </p>	

				
				<p>
					<label><?=lang('term_country')?></label> 
                        <select name='data[country_id]' id="country" <?php if(isset($country_id) && $country_id != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_country')?></option>
                            <?php
                            foreach($countries as $country)
                            {
                            ?>
                            <option value="<?=$country->id?>" <?php if(@$carrier['country_id'] == $country->id){?>selected="selected"<?php }?>><?=$country->country_name?></option>
                            <?php        
                              }
                            ?>
                        </select>
                </p>				
		</fieldset>				
		<fieldset id="bank_information" class="ui-widget-content ui-corner-all">	
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_bank_information')?></legend>
				<p>
					<label><?=lang('term_bank_name')?></label> 
					<input type="text" name="data[bank_name]" id="bank_name" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['bank_name']?>"/> 
                </p>
				<p>
					<label><?=lang('term_bank_address_1')?></label> 
					<input type="text" name="data[bank_address_1]" id="bank_address_1" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['bank_address_1']?>"/> 
                </p>
				<p>
					<label><?=lang('term_bank_address_2')?></label> 
					<input type="text" name="data[bank_address_2]" id="bank_address_2" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['bank_address_2']?>"/> 
                </p>
				<p>
					<label><?=lang('term_bank_city')?></label> 
					<input type="text" name="data[bank_city]" id="bank_city" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['bank_city']?>"/> 
                </p>
				<p>
					<label><?=lang('term_bank_state')?></label> 
					<input type="text" name="data[bank_state]" id="bank_state" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['bank_state']?>"/> 
                </p>
				<p>
					<label><?=lang('term_swift_code')?></label> 
					<input type="text" name="data[swift_code]" id="swift_code" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['swift_code']?>"/> 
                </p>
				<p>
					<label><?=lang('term_account_number')?></label> 
					<input type="text" name="data[account_number]" id="account_number" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['account_number']?>"/> 
                </p>
				<p>
					<label><?=lang('term_account_holder')?></label> 
					<input type="text" name="data[account_holder]" id="account_holder" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['account_holder']?>"/> 
                </p>
				<p>
					<label><?=lang('term_bank_country')?></label> 
					<!--<input type="text" name="data[bank_country]" id="bank_country" class="text ui-widget-content ui-corner-all" /> -->
					
                        <select name='data[bank_country]' id="bank_country" <?php if(isset($bank_country) && $bank_country != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_country')?></option>
                            <?php
                            foreach($countries as $country)
                            {
                            ?>
                            <option value="<?=$country->id?>" <?php if(@$carrier['bank_country'] == $country->id){?>selected="selected"<?php }?>><?=$country->country_name?></option>
                            <?php        
                              }
                            ?>
                        </select>
					
                </p>				
		</fieldset>		
		<fieldset id="company_billing_information" class="ui-widget-content ui-corner-all">	
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_company_billing_information')?></legend>
				<p>
					<label><?=lang('term_company_balance')?></label> 
					<input type="text" name="data[company_balance]" id="company_balance" class="text ui-widget-content ui-corner-all" value="<?=$carrier['company_balance']?>"/> 
                </p>
				<p>
					<label><?=lang('term_company_credit_limit')?></label> 
					<input type="text" name="data[company_credit_limit]" id="company_credit_limit" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['company_credit_limit']?>"/> 
                </p>
				<p>
					<?php
						$default_company_billing_period = $this->MODULE->module_mod_settings->get_setting_item_from_db('default_company_billing_period');
					?>
					<label><?=lang('term_company_billing_period')?></label> 
					<select name="data[company_billing_period]" id="company_billing_period"> 
						<option value="weekly" <?php if($carrier['company_billing_period'] == "weekly"){?>selected = "selected"<?php }?>><?=lang('term_weekly')?></option>
						<option value="bi_monthly" <?php if($carrier['company_billing_period'] == "bi_monthly"){?>selected = "selected"<?php }?>><?=lang('term_bi_monthly')?></option>
						<option value="monthly" <?php if($carrier['company_billing_period'] == "monthly"){?>selected = "selected"<?php }?>><?=lang('term_monthly')?></option>
					</select>
                </p>
				<p>
				  <div class="fields-table">
					<div class="row">
						<label><?=lang('term_company_payment_delay')?></label> 
					</div>
					<div class="row">
						<input type="text" name="data[company_payment_delay]" id="company_payment_delay" value="<?=$carrier['company_payment_delay']?>" class="text ui-widget-content ui-corner-all" /> 
						<span><?=lang('term_days')?></span>
					</div>
				  </div>
                </p>				
		</fieldset>		
		<fieldset id="carrier_billing_information" class="ui-widget-content ui-corner-all">		
		<legend class="ui-widget-content ui-corner-all"><?=lang('term_carrier_billing_information')?></legend>
				<p>
					<label><?=lang('term_carrier_balance')?></label> 
					<input type="text" name="data[carrier_balance]" id="carrier_balance" class="text ui-widget-content ui-corner-all" value="<?=$carrier['carrier_balance']?>"/> 
                </p>
				<p>
					<label><?=lang('term_carrier_credit_limit')?></label> 
					<input type="text" name="data[carrier_credit_limit]" id="carrier_credit_limit" class="text ui-widget-content ui-corner-all"  value="<?=$carrier['carrier_credit_limit']?>"/> 
                </p>				
				<p>
					<?php
						$default_carrier_billing_period = $this->MODULE->module_mod_settings->get_setting_item_from_db('default_carrier_billing_period');
					?>				
					<label><?=lang('term_carrier_billing_period')?></label> 
					<select name="data[carrier_billing_period]" id="carrier_billing_period"> 
						<option value="weekly" <?php if($carrier['carrier_billing_period'] == "weekly"){?>selected = "selected"<?php }?>><?=lang('term_weekly')?></option>
						<option value="bi_monthly" <?php if($carrier['carrier_billing_period'] == "bi_monthly"){?>selected = "selected"<?php }?>><?=lang('term_bi_monthly')?></option>
						<option value="monthly" <?php if($carrier['carrier_billing_period'] == "monthly"){?>selected = "selected"<?php }?>><?=lang('term_monthly')?></option>
					</select>
                </p>
				<p>
				  <div class="fields-table">
					<div class="row">				
						<label><?=lang('term_carrier_payment_delay')?></label> 
					</div>
					<div class="row">				
					<input type="text" name="data[carrier_payment_delay]" id="carrier_payment_delay" value="<?=$carrier['carrier_payment_delay']?>" class="text ui-widget-content ui-corner-all" /> 
					<span><?=lang('term_days')?></span>
					</div>
				  </div>
                </p>
		</fieldset>	
		
		</div>
		<div class="bottom">		
		
				<input type="hidden" name="data[confirm]" id="confirm" value="false"/>
                <div id="response"></div><br />
				<script type="text/javascript">
					var carrier_ID = "<?=$carrier['id']?>";
				</script>
                <button id="module-edit-carrier"><?=lang('button_save')?></button>
		</div>

	 </form> 

	 </div>    
</div>   